/*
 * RecordRankingValues.java
 *
 * Copyright(c) 2011
 * Michael Kroez
 * kroez@studiorutton.de
 *
 * All rights reserved.
 *
 * $Id$
 * 
 */

package de.studiorutton.gerengdic.dictionary.records;

import java.util.Comparator;

public class RecordRankingValues {
	public int index = INFINITE_VALUE;
	public int position = INFINITE_VALUE;
	public int end = INFINITE_VALUE;
	public int cost = INFINITE_VALUE;
	public int errors = INFINITE_VALUE;
	
	public static final int GREATER_THAN = 1;
	public static final int EQUALS = 0;
	public static final int LESS_THAN = -1;
	
	public final static int INFINITE_VALUE = Integer.MAX_VALUE;
	
	public String toString() {
		return "Index = " + index + " Position = " + position + " Cost = " + cost;
	}
	
	public static RRVComparator comparator = new RRVComparator();
	
	public static class RRVComparator implements Comparator<RecordRankingValues> {

		public int compare(RecordRankingValues arg0, RecordRankingValues arg1) {
			if ( arg0.cost > arg1.cost )
				return GREATER_THAN;
			else if ( arg0.cost < arg1.cost )
				return LESS_THAN;
			else {
				if ( arg0.index > arg1.index )
					return GREATER_THAN;
				else if ( arg0.index < arg1.index )
					return LESS_THAN;
				else {
					if ( arg0.position  > arg1.position )
						return GREATER_THAN;
					else if ( arg0.position < arg1.position )
						return LESS_THAN;
					else
						return EQUALS;
				}
			}
		}	
	}
}